package com.comleader.uap.controller;

import static com.comleader.uap.common.response.Result.success;

import java.io.IOException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.comleader.uap.common.response.Result;
import com.comleader.uap.pojo.query.FiveEffectQuery;
import com.comleader.uap.pojo.vo.FiveEffectStatVO;
import com.comleader.uap.service.FiveEffectStatService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @Description 五保成效统计
 * @Auhtor 连新景
 * @Date 2024/11/23 17:08
 */
@Api(tags = "五保成效统计")
@Validated
@RestController
@RequestMapping("/five-effect")
public class FiveEffectStatController {
    @Resource
    private FiveEffectStatService fiveEffectStatService;

    /**
     * @Description 总体指标、列表统计
     * @Auhtor 连新景
     * @Date 2024/12/03 14:42
     * @param query
     * @return com.comleader.uap.common.response.Result<com.comleader.uap.pojo.vo.FiveEffectStatVO>
     */
    @ApiOperation(value = "总体指标和列表统计")
    @PostMapping("/stat")
    public Result<FiveEffectStatVO> list(@Valid @RequestBody FiveEffectQuery query) {
        return success(fiveEffectStatService.fiveEffectStat(query));
    }

    @ApiOperation(value = "导出")
    @PostMapping("/export")
    public void export(@RequestBody FiveEffectQuery query, HttpServletResponse response) throws IOException {
        fiveEffectStatService.export(query, response);
    }

}
